﻿using System.Web.Mvc;
using CandidateManager.Controllers;
using WI.CandidateManager.Business.Objects;
using coach = WI.CandidateManager.Common.Data.Entities.Coach;

namespace CandidateManager.Areas.Admin.Controllers
{
    public class CoachesController : AutorizeBaseController
    {
        private readonly CoachBO coachBO = new CoachBO();

        // GET: /Admin/Coaches/List
        public ActionResult Index()
        {
            return RedirectToAction("List");
        }

        // GET: /Admin/Coaches/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: /Admin/Coaches/Create
        [HttpPost]
        public ActionResult Create(coach coach)
        {
            coachBO.CreateCoach(coach);

            return RedirectToAction("List");
        }

        // GET: /Admin/Coaches/List
        public ActionResult List()
        {
            return View(coachBO.GetCoachesList());
        }

        // GET: /Admin/Coaches/Update/ID
        public ActionResult Update(long id)
        {
            return View(coachBO.GetCoachById(id));
        }

        // POST: /Admin/Coaches/Update
        [HttpPost]
        public ActionResult Update(coach coach)
        {
            coachBO.UpdateCoach(coach);

            return RedirectToAction("List");
        }

        // GET: /Admin/Coaches/Delete/ID
        public ActionResult Delete(long id)
        {
            coachBO.DeleteRecord(id);

            return RedirectToAction("List");
        }
    }
}
